//
//  YMHomeBindDeviceAlert.m
//  YMMedical
//
//  Created by y s on 2023/7/17.
//

#import "YMHomeBindDeviceAlert.h"
#import "YMBingDeviceCodeVC.h"

@interface YMHomeBindDeviceAlert ()

@property (nonatomic, strong) UIImageView *imgvIcon;
@property (nonatomic, strong) UILabel *lblTitle;
@property (nonatomic, strong) UILabel *lblContent;

@property (nonatomic, strong) UIButton *btnGo;


@end

@implementation YMHomeBindDeviceAlert

- (instancetype)init{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

#pragma mark -- UI
- (void)setUI{
    [self.vAlert addSubview:self.imgvIcon];
    [self.vAlert addSubview:self.lblTitle];
    [self.vAlert addSubview:self.lblContent];
    [self.vAlert addSubview:self.btnGo];
    
    [self.imgvIcon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo([SFitUtil fit:20]);
        make.centerX.mas_equalTo(0);
        make.size.mas_equalTo([SFitUtil fitSize:140 height:140]);
    }];
    [self.lblTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imgvIcon.mas_bottom).offset([SFitUtil fit:20]);
        make.centerX.mas_equalTo(0);
    }];
    [self.lblContent mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lblTitle.mas_bottom).offset([SFitUtil fit:20]);
        make.centerX.mas_equalTo(0);
    }];
    [self.btnGo mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.bottom.mas_equalTo([SFitUtil fit:-20]);
        make.size.mas_equalTo([SFitUtil fitSize:120 height:44]);
        make.top.equalTo(self.lblContent.mas_bottom).offset([SFitUtil fit:20]);
    }];
}

- (void)goClickAction:(id)sender{
    YMBingDeviceCodeVC *vc = [[YMBingDeviceCodeVC alloc] init];
    vc.hidesBottomBarWhenPushed = YES;
    [SJumpUtil pushVC:vc animated:YES];
    [self dismiss];
}

#pragma mark -- setter and getter
- (UIImageView *)imgvIcon{
    if (_imgvIcon == nil){
        _imgvIcon = [[UIImageView alloc] init];
        _imgvIcon.image = [UIImage imageNamed:@"home_bind_device_empty"];
    }
    return _imgvIcon;
}
- (UILabel *)lblTitle{
    if (_lblTitle == nil){
        _lblTitle = [SThemeUtil boldLabel:KLanguage(@"bind_device_txt") color:STheme.H_D1 fontSize:18];
    }
    return _lblTitle;
}
- (UILabel *)lblContent{
    if (_lblContent == nil){
        _lblContent = [SThemeUtil label:KLanguage(@"add_device_txt") color:STheme.H_D3 fontSize:14];
    }
    return _lblContent;
}
- (UIButton *)btnGo{
    if (_btnGo == nil) {
        _btnGo = [UIButton buttonWithType:UIButtonTypeCustom];
        _btnGo.titleLabel.font = [SFitUtil fitBoldFont:16];
        [_btnGo setTitleColor:STheme.D9 forState:UIControlStateNormal];
        [_btnGo setTitle:KLanguage(@"to_bind_txt") forState:UIControlStateNormal];
        [_btnGo addTarget:self action:@selector(goClickAction:) forControlEvents:UIControlEventTouchUpInside];
        _btnGo.clipsToBounds = YES;
        _btnGo.layer.cornerRadius = [SFitUtil fit:10];
        _btnGo.backgroundColor = STheme.D12;
    }
    return _btnGo;
}



@end
